package com.bishe.supermarket.service;

import com.bishe.supermarket.mapper.AdminMapper;
import com.bishe.supermarket.pojo.Admin;
import com.bishe.supermarket.pojo.vo.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminLoginService {

    @Autowired
    AdminMapper adminMapper;
    public Status Login(String name,String password){
        //判断用户名和密码是否正确

        Status status = new Status();

        System.out.println("登录名字"+name);
        System.out.println("密码"+password);
       String passWord = adminMapper.selectByName(name);
//Admin admin = list.get(0);
//        System.out.println(list.isEmpty());

//        System.out.println(admin.getPassWord());
        if (passWord==null||!passWord.equals(password)){

            status.setCode(false);
            status.setMsg("管理员名或密码不正确！请重新输入！");
            return status;
        }
        System.out.println("我是数据库的密码"+passWord);
//        System.out.println(list.isEmpty());
//        if (list.isEmpty()){
//        status.setCode(false);
//        status.setMsg("管理员不存在！");
//            return status;
//        }
//        for (Admin a:list
//             ) {
//            System.out.println(a.getLoginName());
//        }
//        System.out.println(list);
//        if (!list.isEmpty()&&!list.get(0).getPassWord().equals(password)){
//
//            status.setCode(false);
//            status.setMsg("密码不正确！");
//            return status;
//
//        }

        status.setCode(true);
        return status;

    }
}
